import numpy as np


def calc_emotion_frequency(series, threshold=0.1) -> np.ndarray:
    emotion = np.zeros_like(series, dtype=int)
    for i in range(1, len(series)):
        emo = series[i] - series[i-1]
        if emo > threshold:
            emotion[i] = 1
        elif emo < threshold:
            emotion[i] = -1
        else:
            emotion[i] = 0
    return emotion


def calc_emotion_series(series) -> np.ndarray:
    emotion = np.zeros_like(series, dtype=float)
    emotion[1:] = np.array(series[1:] - series[:-1])
    emotion = emotion / np.abs(emotion).max()
    return emotion


if __name__ == "__main__":
    a = np.random.random([4])
    c = calc_emotion_series(a)
